<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template.xhtml">
	<ui:define name="corpo">
		<h:form id="cadastroUsuario">
			<h:panelGrid id="panelGridCadastro" columns="2">
				<f:facet name="header">  
	                                        Cadastro do Usuário 
	                                </f:facet>

				<h:outputLabel for="id" value="Id: *" style="display: none" />
				<h:inputHidden id="id" size="50" value="#{usuarioAction.usuario.id}">
				</h:inputHidden>

				<h:outputLabel for="cod" value="CodPermissao: *"
					style="display: none" />
				<h:inputHidden id="cod" size="50"
					value="#{usuarioAction.usuario.codPermissao}">
				</h:inputHidden>

				<h:outputLabel for="nome" value="Nome: *" />
				<h:inputText id="nome" size="50"
					value="#{usuarioAction.usuario.nome}"
					title="Insira o nome do usuário."  label="Nome">
				</h:inputText>

				<h:outputLabel for="email" value="Email: *" />
				<h:inputText id="email" size="50"
					value="#{usuarioAction.usuario.email}"
					title="Insira o email do usuário."  label="Email">
				</h:inputText>

				<h:outputLabel for="telefone" value="Telefone: *" />
				<h:inputText id="telefone" size="50"
					onkeydown="Mascara(this,Telefone);"
					onkeypress="Mascara(this,Telefone);"
					onkeyup="Mascara(this,Telefone);" maxlength="14"
					value="#{usuarioAction.usuario.telefone}"
					title="Insira o telefone do usuário." 
					label="Telefone" />

				<h:outputLabel for="login" value="Login: *" />
				<h:inputText id="login" size="50"
					value="#{usuarioAction.usuario.login}"
					title="Insira o login do usuário."  label="Login">
				</h:inputText>

				<h:outputLabel for="senha" value="Senha: *"
					rendered="#{sessionScope['ID_USUARIO'] == null}" />
				<h:inputSecret id="senha" size="50"
					rendered="#{sessionScope['ID_USUARIO'] == null}"
					value="#{usuarioAction.usuario.senha}"
					title="Insira a senha do usuário."  label="Senha" />

				<h:outputLabel for="confSenha" value="Confirme a Senha: *" 
				rendered="#{sessionScope['ID_USUARIO'] == null}" />
				<h:inputSecret id="confSenha" size="50"
					value="#{usuarioAction.confSenha}"
					rendered="#{sessionScope['ID_USUARIO'] == null}"
					title="Confirme a senha inserida." label="Confirmação da Senha" />

				<h:outputLabel for="aS" value="" style="display: none" rendered="#{sessionScope['ID_USUARIO'] != null}"/>
				<h:outputLabel for="aS" value="Alterar Senha" styleClass="text-info" style="font-weight: bold; position: relative; left: -11px;" rendered="#{sessionScope['ID_USUARIO'] != null}" >
					<p:selectBooleanCheckbox id="checkBoxAlteraSenha" value="#{usuarioAction.alteraSenha}" style="position: relative; top: 4px; left: 4px;" onchange="checkBoxAlterarSenha(this);"></p:selectBooleanCheckbox>
				</h:outputLabel>
				
				<h:outputLabel id="labelSenhaAntiga" for="senhaAntiga" value="Senha Atual: *" style="display: none;"
					rendered="#{sessionScope['ID_USUARIO'] != null}" />
				<h:inputSecret id="senhaAntiga" size="50"
					rendered="#{sessionScope['ID_USUARIO'] != null}"
					value="#{usuarioAction.senhaAntiga}"
					title="Insira sua senha Antiga." style="display: none;"
					label="Senha Antiga" />

				<h:outputLabel id="labelNovaSenha" for="novaSenha" value="Nova Senha: *" style="display: none;"
					rendered="#{sessionScope['ID_USUARIO'] != null}" />
				<h:inputSecret id="novaSenha" size="50"
					rendered="#{sessionScope['ID_USUARIO'] != null}" style="display: none;"
					value="#{usuarioAction.usuario.senha}" title="Insira a senha nova."
					 label="Nova Senha" />

				<h:outputLabel id="labelConfSenhaAtivo" for="confSenhaAtivo" value="Confirme a Senha: *"  style="display: none;"
				rendered="#{sessionScope['ID_USUARIO'] != null}"/>
				<h:inputSecret id="confSenhaAtivo" size="50"
					value="#{usuarioAction.confSenha}" style="display: none;"
					rendered="#{sessionScope['ID_USUARIO'] != null}"
					title="Confirme a senha inserida." 
					label="Confirmação da Senha"/>
					
				<f:facet name="footer">
					<h:commandButton value="Salvar" styleClass="btn"
						style="width: 100%;" action="#{usuarioAction.salvarUsuario}" />
				</f:facet>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
</html>